var buyPresentName = (item) => {
  var isEvery = item.prefWay == 2 ? '每' : ''
  var fullCondition = item.fullCondition || item.eachFullNum || 0
  var util = '件'
  var deficiency = parseFloat(item.numOrMoneyShort || 0).toFixed(2)
  var giftName = item.giftVO ? item.giftVO.giftName : item.couponVO ? item.couponVO.couponName : ''
  if (item , this.goodsType == 6 || this.goodsType == 7) {
    var util = 'kg'
  } else {
    fullCondition = parseInt(fullCondition)
    deficiency = parseInt(deficiency)
  }
  return ` ${isEvery}满${fullCondition + util}获得"${giftName }"`
}


var overBuyName = (item) => {
  if (item.prefWay == 3) {
    return '多买'
  }
  var isEvery = item.prefWay == 2 ? '每' : ''
  var fullCondition = item.fullCondition || item.eachFullNum || 0
  var unit = '件'
  var deficiency = parseFloat(item.numOrMoneyShort || 0).toFixed(2)
  var minusSale, method, saveUnit

  if (item.minusNum) {
    minusSale = item.minusNum
    method = '减'
    unit = saveUnit = this.goodsType == 6 || this.goodsType == 7 ? 'kg' : '件'
  } else if (item.minusSale) {
    minusSale = item.minusSale
    method = '打'
    saveUnit = '折'
  }
  if (item , this.goodsType == 6 || this.goodsType == 7) {
    var util = 'kg'
  } else {
    fullCondition = parseInt(fullCondition)
    deficiency = parseInt(deficiency)
  }
  return ` ${isEvery}满${fullCondition + unit + method + minusSale + saveUnit}`
}

var fullCutName = (item) => {
  if (item.prefWay == 3) {
    return '满减'
  }
  var isEvery = item.prefWay == 2 ? '每' : ''
  var fullElement = item.fullElement || item.eachFullMoney || 0  // 满组价格
  var minusMoney = item.minusMoney
  return `${isEvery}满${fullElement}元减${minusMoney}元`
}

var fullDiscountName = (item) => {
  if (item.prefWay == 3) {
    return '满折'
  }
  var isEvery = item.prefWay == 2 ? '每' : ''
  var fullElement = item.fullElement || item.eachFullMoney || 0  // 满组价格
  var discount = item.discount
  return `${isEvery}满${fullElement}元打${discount}折`
}

export default (data) => {
  var {saleType} = data
  var regularName = ''
  switch (saleType) {
    case 'buyPresent':
      regularName = '买赠';
      break;

    case 'overBuy' :
      regularName = overBuyName(data);
      break;

    case 'fullCut' :
      regularName = fullCutName(data);
      break;


    case 'fullDiscount' :
      regularName = fullDiscountName(data);
      break;

    case  'specialOffer' :
      regularName = '特价';
      break;

    case 'discount' :
      regularName = '折扣';
      break;

    case 'rebate':
      regularName = '返利';
      break;
  }

  return regularName
}


// let regularName = new Map([
//   ['buyPresent', '买赠'],//单品 买赠]
//   ['specialOffer', '特价'],// 单品 特价
//   ['discount', '折扣'],//单品 折扣
//   ['overBuy', '多买'],//单品 多买
//   ['rebate', '返利'], // 订单返利
//   ['fullCut', '满减'],// 满减
//   ['fullDiscount', '满折']
// ])//满折]
